package me.zxk.qwert_poetry.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import me.zxk.qwert_poetry.dao.Poem;
import me.zxk.qwert_poetry.dto.response.PoemDetailResponseDTO;
import me.zxk.qwert_poetry.dto.response.PoemSimpleResponseDTO;
import me.zxk.qwert_poetry.dto.response.Response;
import me.zxk.qwert_poetry.service.PoemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name = "推荐接口", description = "推荐相关接口")
public class FeedController {
    @Autowired
    private PoemService poemService;

    @Operation(summary = "获取首页推荐诗词")
    @GetMapping("/api/feed/home")
    public Response<PoemDetailResponseDTO> getHomeFeed() {
        // HACK 随机获取一首诗词
        return Response.ok(PoemDetailResponseDTO.fromEntity(poemService.getRandomPoem(), poemService));
    }

}
